You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
import { defineWrappedResponseHandler } from "#server/utils/handler";
|
|
import { R } from "#server/utils/response";
|
|
import { getAgentBySlug, getAgentTools } from "#server/service/agent/agent";
|
|
|
|
export default defineWrappedResponseHandler(async (event) => {
|
|
const agentSlug = getRouterParam(event, "agentSlug");
|
|
if (!agentSlug) {
|
|
return R.error("参数无效", null);
|
|
}
|
|
|
|
const agent = await getAgentBySlug(agentSlug);
|
|
if (!agent) {
|
|
return R.error("agent 不存在", null);
|
|
}
|
|
|
|
const tools = await getAgentTools(agent.id);
|
|
|
|
return R.success({
|
|
id: agent.id,
|
|
slug: agent.slug,
|
|
name: agent.name,
|
|
description: agent.description,
|
|
systemPrompt: agent.systemPrompt,
|
|
defaultModelId: agent.defaultModelId,
|
|
titleModelId: agent.titleModelId,
|
|
titleStrategy: agent.titleStrategy,
|
|
enableThinking: agent.enableThinking,
|
|
enableTools: agent.enableTools,
|
|
maxStepCount: agent.maxStepCount,
|
|
isDefault: agent.isDefault,
|
|
isCallable: agent.isCallable,
|
|
tools: tools.map((t) => ({
|
|
id: t.id,
|
|
name: t.name,
|
|
slug: t.slug,
|
|
type: t.type,
|
|
needsApproval: t.needsApproval,
|
|
})),
|
|
});
|
|
});
|
|
|